package com.gitee.theskyzero.actuator;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.stereotype.Repository;

/**
 * @author theskyzero
 * @date 2021/5/24
 */
@Repository
public class MonitorRepository {

    private static final String COUNTER_NAME = "invoke";

    private Counter counter;

    public MonitorRepository(MeterRegistry registry) {
        counter = Counter.builder(COUNTER_NAME).register(registry);
    }

    /**
     * 计数+1
     */
    public void increment() {
        counter.increment();
    }

    public double count() {
        return counter.count();
    }
}
